package org.example.database.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.database.entity.User;

@Mapper
public interface UserMapper {
    /**
     * 根据账号查询用户
     * @param accountNumber 账号
     * @return 用户信息
     */
    @Select("SELECT * FROM user WHERE accountNumber = #{accountNumber}")
    User findByAccountNumber(String accountNumber);

    /**
     * 插入新用户
     * @param user 用户信息
     * @return 影响行数
     */
    @Insert("INSERT INTO user (accountNumber, password,userType, creationTime, modificationTime) " +
            "VALUES (#{accountNumber}, #{password}, #{userType}, #{creationTime}, #{modificationTime})")
    int insert(User user);
}